//剪切板加文章链接
function clipBoard() {

	if (!window.getSelection || !document.querySelector("body")) return;	
  //获取选中的HTML
  var getSelectedContents = function () {
      if (window.getSelection) { //chrome、firefox
          var range = window.getSelection().getRangeAt(0);
          var container = document.createElement('div');
          container.appendChild(range.cloneContents());
          return container.innerHTML;
      } else if (document.selection) { //IE
          return document.selection.createRange().htmlText;
      }
  };
  document.querySelector("body").addEventListener("copy", function(e) {
      var selection = window.getSelection(),
       // copyUrl = location.href,
		//elem = document.createElement("div"),
		description =  getSelectedContents();
		/*elem.innerHTML = description;// + "<br/>" + "链接：" + copyUrl;
		//elem.cssText = "position:absolute;left:-99999px;";
		document.body.appendChild(elem);
       selection.selectAllChildren(elem);
       setTimeout(function () {
          elem.remove();
       }, 0);*/
       
       $.ajax({
			type : "post",
			url : "/log/monitor",
			data : {description:description},
			dataType : "json",
			success : function(data){
			}
		});
       
  });
 
  /*document.querySelector("body").addEventListener("cut", function(e) {
      var selection = window.getSelection(),
        copyUrl = location.href,
		elem = document.createElement("div"),
		description =  getSelectedContents();
		elem.innerHTML = description;// + "<br/>" + "链接：" + copyUrl;
		//elem.cssText = "position:absolute;left:-99999px;";
		document.body.appendChild(elem);
       selection.selectAllChildren(elem);
       setTimeout(function () {
          elem.remove();
       }, 0);
       
       $.ajax({
			type : "post",
			url : "/log/monitor",
			data : {description:description},
			dataType : "json",
			success : function(data){
			}
		});
       
  }); */
  
  
}
clipBoard();

 